package com.kzd.gtgame.main.home

import androidx.fragment.app.Fragment
import com.kzd.gtgame.R
import com.kzd.gtgame.callback.AppPagerAdapter
import com.module.lemlin.owner.OwnerAbstractActivity
import kotlinx.android.synthetic.main.activity_home_service.*

class HomeServiceActivity : OwnerAbstractActivity() {

    companion object {
        private val tabs = arrayOf("今日开服", "即将开服", "历史开服")
    }

    private val mAppPagerAdapter: AppPagerAdapter by lazy {
        object : AppPagerAdapter(supportFragmentManager, tabs) {
            override fun fragment(position: Int): Fragment =
                HomeServiceFragment.newInstance(position)
        }
    }

    override val layoutResId: Int
        get() = R.layout.activity_home_service

    override fun stateBar(): StatusBar {
        return StatusBar(view = flHomeServiceBar)
    }

    override fun initView() {
        tabHomeServiceKind.apply {
            for (item in tabs) {
                addTab(newTab().setText(item))
            }
        }.setupWithViewPager(vpHomeServiceBody.apply {
            adapter = mAppPagerAdapter
        })
    }
}